package ptij.ADSL.common;

public class InitSymbols {

    /* STATES */

    /* Activation and Acknowledgment ATUC */
    public static final int C_QUIET1 = 0;
    public static final int MY_CSILENT1 = 1;
    public static final int C_IDLE = 2;
    public static final int C_TONE = 3;
    public static final int C_ACT = 4;
    public static final int C_QUIET2 = 5;
    
    /* Transceiver Training ATUC */
    public static final int C_REVEILLE = 6;
    public static final int C_PILOT1 = 7;
    public static final int C_REVERB1 = 8;
    public static final int C_PILOT2 = 9;
    public static final int C_ECT = 10;
    public static final int C_REVERB2 = 11;
    public static final int C_PILOT3 = 12;
    public static final int C_REVERB3 = 13;
    
    /* Activation and Acknowledgment ATUR */  
    public static final int R_ACT_REQ = 0;
    public static final int MY_DETECT_C_ACT = 1;
    public static final int R_QUIET1 = 2;
    public static final int R_ACK = 3;

    /* Transceiver Training ATUR */
    public static final int R_QUIET2 = 4;
    public static final int MY_PART_C_PILOT1 = 5;
    public static final int R_REVERB1 = 6;
    public static final int R_QUIET3 = 7;
    public static final int R_ECT = 8;
    public static final int R_REVERB2 = 9;

    public static final int SHOWTIME = 60000;

    /* SYMBOLS */
    
    /* ATUC */
    public static final int C_ACT1_S1 = 0;
    public static final int C_ACT1_S2 = 1;
    public static final int C_ACT2_S1 = 2;
    public static final int C_ACT2_S2 = 3;
    public static final int C_ACT3_S1 = 4;
    public static final int C_ACT3_S2 = 5;
    public static final int C_ACT4_S1 = 6;
    public static final int C_ACT4_S2 = 7;
    public static final int C_REVEILLE_S1 = 8;
    public static final int C_REVEILLE_S2 = 9;
    public static final int C_PILOT_S = 10;
    public static final int C_REVERB_S = 11;
    
    /* ATUR */
    public static final int R_ACT_REQ_S1 = 0;
    public static final int R_ACT_REQ_S2 = 1;
    public static final int R_ACK1_S1 = 2;
    public static final int R_ACK1_S2 = 3;
    public static final int R_ACK2_S1 = 4;
    public static final int R_ACK2_S2 = 5;
    public static final int R_ACK3_S1 = 6;
    public static final int R_ACK3_S2 = 7;
    public static final int R_REVERB_S = 8;
    
    public InitSymbols() {
        /* ATUC */
        _ATUCSymbolTable = new double[12][510];

        _ATUCSymbolTable[C_ACT1_S1][96] = 1;
        _ATUCSymbolTable[C_ACT1_S1][97] = 1;
	
	_ATUCSymbolTable[C_ACT1_S2][96] = 2;
        _ATUCSymbolTable[C_ACT1_S2][97] = 2;
	
        _ATUCSymbolTable[C_ACT2_S1][88] = 1;
        _ATUCSymbolTable[C_ACT2_S1][89] = 1;
	
	_ATUCSymbolTable[C_ACT2_S2][88] = 2;
        _ATUCSymbolTable[C_ACT2_S2][89] = 2;

        _ATUCSymbolTable[C_ACT3_S1][104] = 1;
        _ATUCSymbolTable[C_ACT3_S1][105] = 1;
	
	_ATUCSymbolTable[C_ACT3_S2][104] = 2;
        _ATUCSymbolTable[C_ACT3_S2][105] = 2;

        _ATUCSymbolTable[C_ACT4_S1][120] = 1;
        _ATUCSymbolTable[C_ACT4_S1][121] = 1;
	
	_ATUCSymbolTable[C_ACT4_S2][120] = 2;
        _ATUCSymbolTable[C_ACT4_S2][121] = 2;
	
	_ATUCSymbolTable[C_REVEILLE_S1][112] = 1;
	_ATUCSymbolTable[C_REVEILLE_S1][113] = 1;
	
	_ATUCSymbolTable[C_REVEILLE_S2][112] = 2;
	_ATUCSymbolTable[C_REVEILLE_S2][113] = 2;
	
	_ATUCSymbolTable[C_PILOT_S][128] = 1;
	_ATUCSymbolTable[C_PILOT_S][129] = 1;
	
	for(int i = 0;i < 510;i++) {
	    _ATUCSymbolTable[C_REVERB_S][i] = 1;
	}

        /* ATUR */
	_ATURSymbolTable = new double[9][62];
	
	_ATURSymbolTable[R_ACT_REQ_S1][16] = 1;
	_ATURSymbolTable[R_ACT_REQ_S1][17] = 1;
	
	_ATURSymbolTable[R_ACT_REQ_S2][16] = 2;
	_ATURSymbolTable[R_ACT_REQ_S2][17] = 2;

        _ATURSymbolTable[R_ACK1_S1][20] = 1;
	_ATURSymbolTable[R_ACK1_S1][21] = 1;
	
	_ATURSymbolTable[R_ACK1_S2][20] = 2;
	_ATURSymbolTable[R_ACK1_S2][21] = 2;
	
        _ATURSymbolTable[R_ACK2_S1][24] = 1;
	_ATURSymbolTable[R_ACK2_S1][25] = 1;
	
	_ATURSymbolTable[R_ACK2_S2][24] = 2;
	_ATURSymbolTable[R_ACK2_S2][25] = 2;

        _ATURSymbolTable[R_ACK3_S1][28] = 1;
	_ATURSymbolTable[R_ACK3_S1][29] = 1;
	
	_ATURSymbolTable[R_ACK3_S2][28] = 2;
	_ATURSymbolTable[R_ACK3_S2][29] = 2;
		
	for(int i = 2;i < 62;i++) {
	    _ATURSymbolTable[R_REVERB_S][i] = 1;
	}
    }
    
    public boolean checkATURSymbol(int symbol, double [] value) {
    
        for(int i = 0;i < 62;i++) {
	    if(value[i] != _ATURSymbolTable[symbol][i]) {
	        return false;
	    }
	}
	return true;
    }
    
    public boolean checkATUCSymbol(int symbol, double [] value) {
    
        for(int i = 0;i < 510;i++) {
	    if(value[i] != _ATUCSymbolTable[symbol][i]) {
	        return false;
            }
	}
        return true;
    }

    public double [] getATURSymbol(int symbol) {
    
        return _ATURSymbolTable[symbol];
    }

    public double [] getATUCSymbol(int symbol) {
    
        return _ATUCSymbolTable[symbol];
    }

    private double _ATUCSymbolTable[][];
    private double _ATURSymbolTable[][];
}
